package com.stylefeng.guns.modular.system.warpper;

import com.stylefeng.guns.common.constant.factory.ConstantFactory;
import com.stylefeng.guns.common.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.util.StringUtil;

import java.util.Map;

import org.springframework.util.LinkedCaseInsensitiveMap;

/**
 * 部门列表的包装
 *
 * @author fengshuonan
 * @date 2017年4月25日 18:10:31
 */
public class DeptWarpper extends BaseControllerWarpper {

	public DeptWarpper(Object list) {
		super(list);
	}

	@Override
	public void warpTheMap(Map<String, Object> map) {
		Map<String, Object> tempMap = new LinkedCaseInsensitiveMap<Object>();
		tempMap.putAll(map);
		map.putAll(tempMap);
		Integer pid = Integer.parseInt(StringUtil.nullToDefault(map.get("PID"), "0"));

		if (ToolUtil.isEmpty(pid) || pid.equals(0)) {
			map.put("PNAME", "--");
		} else {
			map.put("PNAME", ConstantFactory.me().getDeptName(pid));
		}
	}

}
